home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / snip9611.zip / ANSICODE.H < prev    next >
C/C++ Source or Header  |  1996-11-24  |  3KB  |  59 lines

  1. /* +++Date last modified: 12-Nov-1996 */
  2.  
  3. #ifndef   ANSICODE__H
  4. #define   ANSICODE__H
  5.  
  6. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  7.  *                                                                     *
  8.  *       ANSICODE.H                                                    *
  9.  *                                                                     *
  10.  *       Macro implementation of ANSI screen control codes             *
  11.  *                                                                     *
  12.  *       Donated to the public domain 96-11-12 by                      *
  13.  *       Tom Torfs (tomtorfs@www.dma.be, 2:292/516@fidonet)            *
  14.  *                                                                     *
  15.  *       Based on code originally contributed to the public domain on  *
  16.  *       12-26-91 by by Matthew J. Glass.                              *
  17.  *                                                                     *
  18.  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  19.  
  20. #include <stdio.h>
  21.  
  22. enum {ANSI_NORMAL=0,   ANSI_BOLD=1,     ANSI_UNDER=4,
  23.       ANSI_BLINK=5,    ANSI_REVERSE=7,  ANSI_HIDDEN=8};
  24.  
  25. enum {ANSI_BLACK=0,    ANSI_RED=1,      ANSI_GREEN=2,
  26.       ANSI_YELLOW=3,   ANSI_BROWN=3,    ANSI_BLUE=4,
  27.       ANSI_MAGENTA=5,  ANSI_CYAN=6,     ANSI_WHITE=7};
  28.  
  29. enum {ANSI_40x25_BW=0,     ANSI_40x25=1,
  30.       ANSI_80x25_BW=2,     ANSI_80x25=3,
  31.       ANSI_320x200x4=4,    ANSI_320x200x2=5,
  32.       ANSI_640x200x2=6,    ANSI_LINEWRAP=7,
  33.       ANSI_320x200x16=13,  ANSI_640x200x16=14,
  34.       ANSI_640x350x2=15,   ANSI_640x350x16=16,
  35.       ANSI_640x480x2=17,   ANSI_640x480x16=18,
  36.       ANSI_320x200x256=19};
  37.  
  38. #define ANSI_home()        printf("\x1B[H")
  39. #define ANSI_locate(x,y)   printf("\x1B[%d;%dH",(int)(y),(int)(x))
  40. #define ANSI_up(lines)     printf("\x1B[%dA",(int)(lines))
  41. #define ANSI_down(lines)   printf("\x1B[%dB",(int)(lines))
  42. #define ANSI_right(cols)   printf("\x1B[%dC",(int)(cols))
  43. #define ANSI_left(cols)    printf("\x1B[%dD",(int)(cols))
  44. #define ANSI_save()        printf("\x1B[s")
  45. #define ANSI_restore()     printf("\x1B[u")
  46. #define ANSI_cls()         printf("\x1B[2J")
  47. #define ANSI_clreol()      printf("\x1B[K")
  48. #define ANSI_attrib(attr)  printf("\x1B[%dm",(int)(attr))
  49. #define ANSI_fgcolor(fc)   printf("\x1B[%dm",(int)(fc)+30)
  50. #define ANSI_bgcolor(bc)   printf("\x1B[%dm",(int)(bc)+40)
  51. #define ANSI_fullcolor(bc) printf("\x1B[%d;%dm",(int)(fc)+30,(int)(bc)+40)
  52. #define ANSI_attrcolor(fc,bc,attr) \
  53.              printf("\x1B[%d;%d;%dm",(int)(fc)+30,(int)(bc)+40,(int)(attr))
  54. #define ANSI_videomode(nr) printf("\x1B[=%dh",(int)(nr))
  55. #define ANSI_resetmode(nr) printf("\x1B[=%dl",(int)(nr))
  56. #define ANSI_report()      printf("\x1B[6n")
  57.  
  58. #endif /* ANSICODE__H */
  59.